package gatech.cs2340.adventuretime.persistent;

import java.util.Date;

/**
 * Our datastore user superclass
 * @author Win Nadeau
 */
public class User {
	/**
	 * a unique email address
	 */
	private String username;
	/**
	 * a password with certain TBD constraints
	 */
	private String password;
	/**
	 * date created/joined
	 */
	private Date creationDate;
	/**
	 * no constraints
	 */
	private String name;
	/**
	 * this is a DB flag to help constrain users to one session
	 */
	private boolean inUse;
	
 
	/**
	 * constructor that validates username/password 
	 * @param username must be a valid email address
	 * @param password must be more than 5 characters for now
	 */
	public User (String username, String password){
		/**
		 * TODO: REGEX this shit for validation
		 */
		this.username = username;
		this.password = password;
		this.creationDate = new Date();
		this.setInUse(false);
	}
	
	// the following protected constructors and methods are for db querying
	
	protected User() {
		
	}	

	protected void setUsername(String username) {
		this.username = username;
	}	
	protected void setPassword(String password) {
		this.password = password;
	}	
	protected void setCreationDate(Date date) {
		this.creationDate = date;
	}
	
	//TODO create constructor chain for other data fields, like name and anything else we'll add
	public Date getCreationDate() {
		return creationDate;
	}
	/**
	 * This is how the server will validate users easily
	 * @param passwordAttempt
	 * @return true only if the strings match exactly
	 */
	public boolean passwordCheck(String passwordAttempt){
		if (this.password.equals(passwordAttempt)){
			return true;
		}
		return false;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}
	public String getUsername() {
		return username;
	}
	public void setInUse(boolean inUse) {
		this.inUse = inUse;
	}
	public boolean isInUse() {
		return inUse;
	}
	
	
	

}
